{include file="common/head"/}
<style>
    .layui-table-cell{height: auto;}
    .layui-table-cell ul li a{color: #1C8FEF;display: block;border: 1px solid #ececec;padding: 3px 8px;}
    .layui-table-cell ul li a:hover{color: #005580}
</style>
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>提交列表</legend>
    </fieldset>

    <table class="layui-table" id="list" lay-filter="list"></table>
</div>
</div>

{include file="common/foot"/}

<script type="text/html" id="submit_status">
    {{# if(d.submit_status=='1'){ }}
    <span class="layui-btn layui-btn-xs layui-btn-warm">已保存</span>
    {{# }else if(d.submit_status=='2'){ }}
    <span class="layui-btn layui-btn-xs layui-btn-danger ">已提交</span>
    {{# }else{ }}
    <span class="layui-btn layui-btn-xs ">待编辑</span>
    {{# } }}
</script>

<script type="text/html" id="status">
    {{# if(d.status==2){ }}
    <span class="layui-btn layui-btn-xs layui-btn-danger">驳回</span>
    {{# }else if(d.status==1){ }}
    <span class="layui-btn layui-btn-xs">通过</span>
    {{# }else{ }}
    {{# if(d.submit_status=='2'){ }}
    <span class="layui-btn layui-btn-xs layui-btn-warm">待审核</span>
    {{# } }}
    {{# } }}
</script>

<script type="text/html" id="barDemo">
    {{# if(d.submit_status=='1'){ }}
    <a class="layui-btn  layui-btn-xs" lay-event="submit">提交</a>
    {{# }else{ }}
    <a class="layui-btn  layui-btn-xs layui-btn-disabled">提交</a>
    {{# } }}
</script>

<script>
    layui.use(['table','element','laydate','form','layer'], function() {
        var table = layui.table, form = layui.form, $ = layui.jquery, layer = layui.layer, laydate = layui.laydate;

        var tableIn = table.render({
            id: 'user',
            elem: '#list',
            url: "{:url('lists')}",
            method: 'post',
            page: true,
            even:true,
            cols: [[
                {field: 'title',title: '考核项分类名称', width: 150},
                {field: 'submit_status',title: '提交状态', width: 150,templet:'#submit_status'},
                {field: 'status',title: '审查状态', width: 150,templet:'#status'},
                {title: '操作',width: 160, align: 'center', toolbar: '#barDemo'}
            ]],
            limit: 10, //每页默认显示的数量
            done: function(res, curr, count){
                console.log(res.tongji);
                $('.layui-laypage-limits').append(" <span class=\"layui-laypage-limits\" style='margin-left: 100px;font-size: 16px'>"+res.check_name+"</span>");

            }
        });
        table.on('tool(list)', function(obj){

            var data = obj.data;
            if(obj.event === 'submit') {
                layer.confirm("你确定要提交吗？", function (index) {
                    $.post("{:url('submit')}", {cate_id: data.cate_id}, function (res) {
                        if (res.code == 1) {
                            layer.msg(res.msg, {time: 1000, icon: 1});
                            location.href = "{:url('lists')}";
                        } else {
                            layer.msg(res.msg, {time: 1000, icon: 2});
                        }
                    });

                });
            }

        });

    });
</script>
</body>
</html>